package net.cyndeline.scalarlib.rldungeon.dgs.strategy.pointlessArea.algorithms.help

import net.cyndeline.scalarlib.rldungeon.dgs.graph.{PointlessAreaData, Room}

/**
 * Sets the pointless status of one or more vertices. Mainly used so the process can be mocked out in tests,
 * as the actual implementation is very simply.
 */
trait RoomModifierInterface {

  /**
   * Sets a seq of vertices to a specified pointless status.
   * @param status True if vertices should be made pointless, false if they should be marked as meaningful.
   * @param vertices All vertices to set status for.
   * @tparam V Type of vertex.
   * @return A map of all the old vertices as keys, and the new vertices as values.
   */
  def setPointlessStatus[V <: Room[V]](status: Boolean, vertices: Set[V]): Map[V, V]

  /**
   * Adds a pointless area data object to a set of rooms.
   * @param data Data to add to every room.
   * @param vertices The set of rooms to add data to.
   * @tparam V Type of room.
   * @return A map of all the old vertices as keys, and the new vertices with the added data as values.
   */
  def addPointlessAreaData[V <: Room[V]](data: PointlessAreaData[V], vertices: Set[V]): Map[V, V]
}

/**
 * @constructor Create a new room modifier.
 */
class RoomModifier extends RoomModifierInterface {
  def setPointlessStatus[V <: Room[V]](status: Boolean, vertices: Set[V]): Map[V, V] = {
    vertices.map(v => v -> v.withPointlessStatus(status)).toMap
  }

  def addPointlessAreaData[V <: Room[V]](data: PointlessAreaData[V], vertices: Set[V]): Map[V, V] = {
    vertices.map(v => v -> v.withPointlessData(data)).toMap
  }
}
